﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Camc.OutsourceProcession.Migrations.SCDDb
{
    public partial class PrintEquipment132s : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Aaas",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    dad = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Aaas", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AppUserInfos",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    Openid = table.Column<string>(nullable: true),
                    Userid = table.Column<long>(nullable: false),
                    NickName = table.Column<string>(nullable: true),
                    AvatarUrl = table.Column<string>(nullable: true),
                    Gender = table.Column<int>(nullable: false),
                    City = table.Column<string>(nullable: true),
                    Province = table.Column<string>(nullable: true),
                    Country = table.Column<string>(nullable: true),
                    Language = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppUserInfos", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Contacts",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CompanyName = table.Column<string>(nullable: true),
                    Address = table.Column<string>(nullable: true),
                    Contacts = table.Column<string>(nullable: true),
                    Telephone = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Contacts", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "LineTemplates",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    TemplateName = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LineTemplates", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "PrintEquipments",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    SN = table.Column<string>(nullable: true),
                    CompanyCode = table.Column<string>(nullable: true),
                    Location = table.Column<string>(nullable: true),
                    Remark = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PrintEquipments", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "WorkingTeams",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    MemberList = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorkingTeams", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "WorkStations",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    StationName = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorkStations", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Orders",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    PicNo = table.Column<string>(nullable: true),
                    TaskNo = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    Amount = table.Column<int>(nullable: false),
                    Size = table.Column<string>(nullable: true),
                    DeliveryTime = table.Column<DateTime>(nullable: false),
                    State = table.Column<int>(nullable: false),
                    Materials = table.Column<string>(nullable: true),
                    Technician = table.Column<string>(nullable: true),
                    Auditor = table.Column<string>(nullable: true),
                    AuditTime = table.Column<DateTime>(nullable: false),
                    Remark = table.Column<string>(nullable: true),
                    IsUrgency = table.Column<bool>(nullable: false),
                    CustomerId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Orders", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Orders_Contacts_CustomerId",
                        column: x => x.CustomerId,
                        principalTable: "Contacts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "LineInstances",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    TemplateName = table.Column<string>(nullable: true),
                    ProductionDrawingCode = table.Column<string>(nullable: true),
                    ProductionSpecial = table.Column<string>(nullable: true),
                    TaskModel = table.Column<string>(nullable: true),
                    TaskKey = table.Column<string>(nullable: true),
                    State = table.Column<int>(nullable: false),
                    Quantity = table.Column<int>(nullable: false),
                    DeliveryTime = table.Column<DateTime>(nullable: false),
                    WorkingTeamId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LineInstances", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LineInstances_WorkingTeams_WorkingTeamId",
                        column: x => x.WorkingTeamId,
                        principalTable: "WorkingTeams",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "NodeBases",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    NodeCode = table.Column<string>(nullable: true),
                    NodeName = table.Column<string>(nullable: true),
                    WorkStationId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_NodeBases", x => x.Id);
                    table.ForeignKey(
                        name: "FK_NodeBases_WorkStations_WorkStationId",
                        column: x => x.WorkStationId,
                        principalTable: "WorkStations",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "NodeForTemplates",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    NodeCode = table.Column<string>(nullable: true),
                    NodeName = table.Column<string>(nullable: true),
                    WorkStationId = table.Column<Guid>(nullable: false),
                    OrderIndex = table.Column<int>(nullable: false),
                    LineTemplateId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_NodeForTemplates", x => x.Id);
                    table.ForeignKey(
                        name: "FK_NodeForTemplates_LineTemplates_LineTemplateId",
                        column: x => x.LineTemplateId,
                        principalTable: "LineTemplates",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_NodeForTemplates_WorkStations_WorkStationId",
                        column: x => x.WorkStationId,
                        principalTable: "WorkStations",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Processes",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    OrderId = table.Column<long>(nullable: false),
                    Name = table.Column<string>(nullable: true),
                    TimeOfPreparation = table.Column<decimal>(nullable: false),
                    TimeOfManufacture = table.Column<decimal>(nullable: false),
                    Maker = table.Column<string>(nullable: true),
                    Amount = table.Column<int>(nullable: false),
                    IsPivotal = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Processes", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Processes_Orders_OrderId",
                        column: x => x.OrderId,
                        principalTable: "Orders",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ProductLogs",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    OrderId = table.Column<long>(nullable: false),
                    Operator = table.Column<string>(nullable: true),
                    Events = table.Column<string>(nullable: true),
                    Remark = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductLogs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ProductLogs_Orders_OrderId",
                        column: x => x.OrderId,
                        principalTable: "Orders",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "SpecialTools",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    OrderId = table.Column<long>(nullable: false),
                    Name = table.Column<string>(nullable: true),
                    Length = table.Column<string>(nullable: true),
                    LengthOfEdge = table.Column<string>(nullable: true),
                    LengthOfHandle = table.Column<string>(nullable: true),
                    Explain = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SpecialTools", x => x.Id);
                    table.ForeignKey(
                        name: "FK_SpecialTools_Orders_OrderId",
                        column: x => x.OrderId,
                        principalTable: "Orders",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "LineInstanceExecuteHistorys",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    LineInstanceId = table.Column<Guid>(nullable: false),
                    OrderIndex = table.Column<int>(nullable: false),
                    StartTime = table.Column<DateTime>(nullable: false),
                    ExecutorAccount = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LineInstanceExecuteHistorys", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LineInstanceExecuteHistorys_LineInstances_LineInstanceId",
                        column: x => x.LineInstanceId,
                        principalTable: "LineInstances",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "NodeForInstances",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    NodeCode = table.Column<string>(nullable: true),
                    NodeName = table.Column<string>(nullable: true),
                    WorkStationId = table.Column<Guid>(nullable: false),
                    OrderIndex = table.Column<int>(nullable: false),
                    LineInstanceId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_NodeForInstances", x => x.Id);
                    table.ForeignKey(
                        name: "FK_NodeForInstances_LineInstances_LineInstanceId",
                        column: x => x.LineInstanceId,
                        principalTable: "LineInstances",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_NodeForInstances_WorkStations_WorkStationId",
                        column: x => x.WorkStationId,
                        principalTable: "WorkStations",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "RequestBases",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    RequesterId = table.Column<string>(nullable: true),
                    RequestInfo = table.Column<string>(nullable: true),
                    Responder = table.Column<string>(nullable: true),
                    RespondTime = table.Column<DateTime>(nullable: false),
                    RespondInfo = table.Column<string>(nullable: true),
                    RespondOperation = table.Column<string>(nullable: true),
                    LineInstanceId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RequestBases", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RequestBases_LineInstances_LineInstanceId",
                        column: x => x.LineInstanceId,
                        principalTable: "LineInstances",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_LineInstanceExecuteHistorys_LineInstanceId",
                table: "LineInstanceExecuteHistorys",
                column: "LineInstanceId");

            migrationBuilder.CreateIndex(
                name: "IX_LineInstances_WorkingTeamId",
                table: "LineInstances",
                column: "WorkingTeamId");

            migrationBuilder.CreateIndex(
                name: "IX_NodeBases_WorkStationId",
                table: "NodeBases",
                column: "WorkStationId");

            migrationBuilder.CreateIndex(
                name: "IX_NodeForInstances_LineInstanceId",
                table: "NodeForInstances",
                column: "LineInstanceId");

            migrationBuilder.CreateIndex(
                name: "IX_NodeForInstances_WorkStationId",
                table: "NodeForInstances",
                column: "WorkStationId");

            migrationBuilder.CreateIndex(
                name: "IX_NodeForTemplates_LineTemplateId",
                table: "NodeForTemplates",
                column: "LineTemplateId");

            migrationBuilder.CreateIndex(
                name: "IX_NodeForTemplates_WorkStationId",
                table: "NodeForTemplates",
                column: "WorkStationId");

            migrationBuilder.CreateIndex(
                name: "IX_Orders_CustomerId",
                table: "Orders",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_Processes_OrderId",
                table: "Processes",
                column: "OrderId");

            migrationBuilder.CreateIndex(
                name: "IX_ProductLogs_OrderId",
                table: "ProductLogs",
                column: "OrderId");

            migrationBuilder.CreateIndex(
                name: "IX_RequestBases_LineInstanceId",
                table: "RequestBases",
                column: "LineInstanceId");

            migrationBuilder.CreateIndex(
                name: "IX_SpecialTools_OrderId",
                table: "SpecialTools",
                column: "OrderId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Aaas");

            migrationBuilder.DropTable(
                name: "AppUserInfos");

            migrationBuilder.DropTable(
                name: "LineInstanceExecuteHistorys");

            migrationBuilder.DropTable(
                name: "NodeBases");

            migrationBuilder.DropTable(
                name: "NodeForInstances");

            migrationBuilder.DropTable(
                name: "NodeForTemplates");

            migrationBuilder.DropTable(
                name: "PrintEquipments");

            migrationBuilder.DropTable(
                name: "Processes");

            migrationBuilder.DropTable(
                name: "ProductLogs");

            migrationBuilder.DropTable(
                name: "RequestBases");

            migrationBuilder.DropTable(
                name: "SpecialTools");

            migrationBuilder.DropTable(
                name: "LineTemplates");

            migrationBuilder.DropTable(
                name: "WorkStations");

            migrationBuilder.DropTable(
                name: "LineInstances");

            migrationBuilder.DropTable(
                name: "Orders");

            migrationBuilder.DropTable(
                name: "WorkingTeams");

            migrationBuilder.DropTable(
                name: "Contacts");
        }
    }
}
